bunzip2: off by one in get_next_block()
authorDan Carpenter <dan.carpenter@oracle.com>
Wed, 28 Jan 2015 15:50:08 +0000 (16:50 +0100)
committerJan Beulich <jbeulich@suse.com>
Wed, 28 Jan 2015 15:50:08 +0000 (16:50 +0100)
"origPtr" is used as an offset into the bd->dbuf[] array.  That array is
allocated in start_bunzip() and has "bd->dbufSize" number of elements so
the test here should be >= instead of >.

Later we check "origPtr" again before using it as an offset so I don't
know if this bug can be triggered in real life.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Trivial adjustments to make the respective Linux commit
b5c8afe5be51078a979d86ae5ae78c4ac948063d apply to Xen.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
xen/common/bunzip2.c

index 2eb70ab6c463cf16b7c62d9b2e1e060fae58a6f0..6d6e8b19fdd7b1f09f841c59a1b63b2e2356d10b 100644 (file)
@@ -174,7 +174,7 @@ static int INIT get_next_block(struct bunzip_data *bd)
        if (get_bits(bd, 1))
                return RETVAL_OBSOLETE_INPUT;
        origPtr = get_bits(bd, 24);
-       if (origPtr > dbufSize)
+       if (origPtr >= dbufSize)
                return RETVAL_DATA_ERROR;
        /* mapping table: if some byte values are never used (encoding things
           like ascii text), the compression code removes the gaps to have fewer